﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.AppearanceModelCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.AppearanceModelCommandHandler
{
    public class AppearanceModelUpdateCommandHandler : IRequestHandler<AppearanceModelUpdateCommand, Results<int>>
    {


        private readonly IAppearanceModelService appearanceModelService;
        private readonly ILogger<AppearanceModelUpdateCommandHandler> logger;
        public AppearanceModelUpdateCommandHandler(IAppearanceModelService appearanceModelService, ILogger<AppearanceModelUpdateCommandHandler> logger)
        {
            this.appearanceModelService = appearanceModelService;
            this.logger = logger;
        }


        public async Task<Results<int>> Handle(AppearanceModelUpdateCommand request, CancellationToken cancellationToken)
        {
            var result = new Appearancemodel()
            {
                AppearanceId = request.AppearanceId,
                EarTag = request.EarTag,
                MeasureDate = request.MeasureDate,
                Tooth = request.Tooth,
                Hair = request.Hair,
                Stain = request.Stain,
                HoofColor = request.HoofColor,
                MouthColor = request.MouthColor,
                Angle = request.Angle,
                FatDistribution = request.FatDistribution,
            };
            var list = await appearanceModelService.Update(result);
            return Results<int>.DataResult(list);
        }





    }



}
